﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DemoBullet : MonoBehaviour {
    public GameObject target;
    private float passTime = 0;
    public float totalTime = 1;

    private Vector3 initPos;
    void Start()
    {
        initPos = transform.position;
        target = DemoEnemy.Instance.gameObject;
    }
	
	// Update is called once per frame
	void Update () {
        passTime += Time.deltaTime;
        var rate = passTime / totalTime;
        rate = Mathf.Clamp01(rate);
        var np = Vector3.Lerp(initPos, target.transform.position, rate);
        transform.position = np;
        if (rate >= 1)
        {
            GameObject.Destroy(gameObject);
        }
	}
}
